package com.itec.learn.java.design.singleton.doublecheck;

/**
 *
 */
public class VolatileDoubleCheck {

    // volatile 保证单例被初始化后能够被所有的线程可见
    private volatile static VolatileDoubleCheck instance = null;

    private VolatileDoubleCheck(){

    }

    public static VolatileDoubleCheck getInstance(){
        if(instance == null){
            synchronized (VolatileDoubleCheck.class){
                if (instance == null){
                    instance = new VolatileDoubleCheck();
                }
            }
        }
        return instance;
    }
}
